package com.primeton.sftp.util;

import com.jcraft.jsch.SftpException;
import com.primeton.sftp.excel.ExcelUtil;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.TimerTask;

public class MonthTask extends TimerTask {

    // 每个月5号传上个月的
    private static String taskTime = "25";
    private static Logger logger = LoggerFactory.getLogger(MonthTask.class);
    @Override
    public void run() {
        logger.info("月传任务");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String s = df.format(new Date());// new Date()为获取当前系统时间
        String s1 = s.split(" ")[0]; // 2022-02-23
        String s2 = s1.substring(s1.lastIndexOf("-")+1,s1.length()); // 23
        if (s2.equals(taskTime)){
            logger.info("月传开始！");
            SFTPUtil.uploadMonth();
        }
    }
}
